-
Notifications
You must be signed in to change notification settings - Fork 683
DATACMNS-1190 - Added section on how to enforce nullability constraints on repositories #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ts on repositories. Original pull request: #253.
5a449ba
to
1f12660
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change duplicates already existing documentation. Merging what we have with this change and leaving it below Defining repository interfaces
seems a good fit.
src/main/asciidoc/repositories.adoc
Outdated
The absence of a query result will then be indicated by returning `null`. | ||
Repository methods returning collection like values will never return null but an empty value. | ||
|
||
[[repositories.nullability.annotations]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section duplicates the section on Null-safety that is currently in place. It would make sense to move core.nullability-validation
in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After revisiting the other version of the docs, I'd actually like to keep this one here and augment it with the following aspects currently present in the other version:
- Nullability annotations should list the fully-qualified name at least once, so that it's clear what to import. I think we can (should?) leave out the remark with JSR-305 needed for meta-annotation usage. That's taking it a bit too far I think.
- The
kotlin-reflect
library needed to get the runtime checks enabled.
src/main/asciidoc/repositories.adoc
Outdated
|
||
Alternatively query methods can choose not to use a wrapper type at all. | ||
The absence of a query result will then be indicated by returning `null`. | ||
Repository methods returning collection like values will never return null but an empty value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about Repository methods returning collections, wrappers, and streams are guaranteed to never return null but rather the corresponding empty representation.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should link to the appendix table listing all supported return types as they also list the alternative collection types we support that might be handy to know about but don't need any discussion here.
src/main/asciidoc/repositories.adoc
Outdated
==== Nullability in Kotlin-based repositories | ||
|
||
Kotlin has the definition of nullability constraints baked into the language. | ||
Spring Data repositories using the language mechanism to define those constraints will automatically get the same runtime checks applied: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good place to mention the need to have kotlin-reflect
on the classpath.
Remove existing section on Null-safety. Augment Null handling section with bits of the previous documentation, explicitly describe annotations expressing null-constraints, include full-qualified imports, mention kotlin-reflect dependency for Kotlin metadata introspection. Align callouts, add links, slightly improve wording, typos. Extend year range in copyright header.
d7bfa82
to
fe4a09d
Compare
…ts on repositories. Original pull request: #253.
Remove existing section on Null-safety. Augment Null handling section with bits of the previous documentation, explicitly describe annotations expressing null-constraints, include full-qualified imports, mention kotlin-reflect dependency for Kotlin metadata introspection. Align callouts, add links, slightly improve wording, typos. Extend year range in copyright header. Original pull request: #253.
Slight rewording. Extracted path to Spring Framework JavaDoc into variable. Original pull request: #253.
Slight rewording. Extracted path to Spring Framework JavaDoc into variable. Original pull request: #253.
Slight rewording. Extracted path to Spring Framework JavaDoc into variable. Original pull request: #253.
…ts on repositories. Original pull request: #253.
Remove existing section on Null-safety. Augment Null handling section with bits of the previous documentation, explicitly describe annotations expressing null-constraints, include full-qualified imports, mention kotlin-reflect dependency for Kotlin metadata introspection. Align callouts, add links, slightly improve wording, typos. Extend year range in copyright header. Original pull request: #253.
Slight rewording. Extracted path to Spring Framework JavaDoc into variable. Original pull request: #253.
No description provided.